package blackhouse_dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import blackhouse_entity.student;

public class student_dao extends jdbc_dao
{
	public List<student> show_student(String sql, String code)
			throws SQLException
	{
		List<student> list = new ArrayList<student>();
		ResultSet RS = query(sql);
		while (RS.next())
		{
			student stuinfo = new student();
			stuinfo.setId(RS.getInt("id"));
			stuinfo.setStuCode(RS.getString("stuCode"));
			stuinfo.setStuName(RS.getString("stuName"));
			stuinfo.setStuAge(RS.getInt("stuAge"));
			stuinfo.setStuSex(RS.getString("stuSex"));
			stuinfo.setStuQQ(RS.getString("stuQQ"));
			stuinfo.setStuPhone(RS.getString("stuPhone"));
			stuinfo.setStuAddress(RS.getString("stuAddress"));
			if (code.equals("4"))
			{
				stuinfo.setStuclassid(RS.getString("className"));
			}
			list.add(stuinfo);
		}

		close(conn, st, RS);
		return list;
	}

	public int changeinfo(String sql)
	{
		int num = update(sql);
		return num;
	}

	public boolean addStudentInfo(String sql, List<Object> list)
			throws SQLException
	{
		return execute_Proc(sql, list);
	}

}
